package com.guoxin.artconcurrency.chapter8;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

/**
 * @author guoxin
 * @date 2019/8/6
 */
public class CyclicBarrierTest3 {
    private static CyclicBarrier cb = new CyclicBarrier(2);

    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    cb.await();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (BrokenBarrierException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        thread.interrupt();
        try {
            cb.await();
        } catch (InterruptedException | BrokenBarrierException e) {
            System.out.println(cb.isBroken());
        }
    }

}
